package com.rgz.controller.ccxController;


import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

 
import org.apache.commons.codec.binary.Base64;


import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;





public class AliyunImageOrc {
	static BASE64Encoder encoder = new sun.misc.BASE64Encoder();
	static BASE64Decoder decoder = new sun.misc.BASE64Decoder();
 
	/**
	 * 获取图片的base64编码数据
	 * </p>
	 * 
	 * @param imagePath
	 * @return
	 */
	public static String getImageBinaryToString(String imagePath) {
		try {
			File file = new File(imagePath);
			byte[] content = new byte[(int) file.length()];
			FileInputStream finputstream = new FileInputStream(file);
			finputstream.read(content);
			finputstream.close();
			return new String(Base64.encodeBase64(content));
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}
 


}
